import { RoleEntity } from './entities/role.entity';
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { FindManyOptions, Repository } from 'typeorm';
import { RoleWidthPermEntity } from './entities/role-width-perm.entity';

@Injectable()
export class RoleService {
  constructor(
    @InjectRepository(RoleEntity)
    private readonly roleEntityRep: Repository<RoleEntity>,
    @InjectRepository(RoleWidthPermEntity)
    private readonly roleWidthPermEntityRep: Repository<RoleWidthPermEntity>,
  ) {}
  async findAll() {
    return await this.roleEntityRep.find();
  }

  findRoles(where: FindManyOptions<RoleEntity>) {
    return this.roleEntityRep.find(where);
  }

  findRoleWidthPerm(where: FindManyOptions<RoleWidthPermEntity>) {
    return this.roleWidthPermEntityRep.find(where);
  }
}
